<?php
/**
 * Created by PhpStorm.
 * User: yangyulu
 * Date: 2020/3/3
 * Time: 下午4:21
 */

class voteModel extends Model{
    public function Exhibition($ids){
        $res=$this->update(["is_default"=>1],["id=?"],[$ids]);
        if($res){
            $res=$this->update(["is_default"=>0],["id!=?"],[$ids]);
            $this->RedisCash($ids);
        }
        return $res;
    }

    public function RedisCash($ids){
        $redis=new Cache_Redis();
        $info=$this->fields("id,problem")->getOne("id=?",$ids);
        $redis->set("vote_details",$info);
        $option_list=self::model("vote_option")->fields("id,vote_option as `option`")->getAll(["vote_id=?","is_delete=?"],[$ids,0]);
        $redis->set("option_list",$option_list);
    }
}